﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.css {
    import reprise.css.*;
    import flash.utils.*;

    class CSSDeclarationList {

        protected var m_declarationIndex:int;// = 0
        protected var m_items:Array;
        protected var m_selectorHeadParts:Object;
        protected var m_starSelectors:Array;
        protected var m_declarationCache:Array;

        function CSSDeclarationList(){
            m_selectorHeadParts = {};
            m_starSelectors = [];
            super();
            m_items = [];
            m_declarationCache = [];
        }
        function getStyleForSelectorsPath(_arg1:String):CSSDeclaration{
            var _local5:CSSDeclarationListItem;
            var _local9:Array;
            var _local10:int;
            var _local2:CSSDeclaration = m_declarationCache[_arg1];
            if (_local2){
                return (_local2);
            };
            var _local3:Array = [];
            var _local4:Dictionary = new Dictionary(true);
            _local2 = new CSSDeclaration();
            var _local6:Array = _arg1.split(" ").pop().split("@");
            var _local7:int = _local6.length;
            while (_local7--) {
                _local9 = m_selectorHeadParts[_local6[_local7]];
                if (!_local9){
                } else {
                    _local10 = _local9.length;
                    while (_local10--) {
                        _local5 = _local9[_local10];
                        if (((_local5) && (!(_local4[_local5])))){
                            _local4[_local5] = true;
                            if (_local5.matchesSubjectPath(_arg1)){
                                _local3.push(_local5);
                            };
                        };
                    };
                };
            };
            _local10 = m_starSelectors.length;
            while (_local10--) {
                _local5 = m_starSelectors[_local10];
                if (((_local5) && (!(_local4[_local5])))){
                    _local4[_local5] = true;
                    if (_local5.matchesSubjectPath(_arg1)){
                        _local3.push(_local5);
                    };
                };
            };
            _local3.sortOn(["declarationSpecificity", "declarationIndex"], (Array.NUMERIC | Array.DESCENDING));
            _local7 = _local3.length;
            var _local8:String = _local3.toString();
            if (m_declarationCache[_local8]){
                _local2 = m_declarationCache[_local8];
                m_declarationCache[_arg1] = _local2;
                return (CSSDeclaration(_local2));
            };
            if (_local7 == 1){
                _local2 = CSSDeclarationListItem(_local3[0]).declaration();
            } else {
                while (_local7--) {
                    _local2.mergeCSSDeclaration(CSSDeclarationListItem(_local3[_local7]).declaration());
                };
            };
            m_declarationCache[_arg1] = _local2;
            m_declarationCache[_local8] = _local2;
            return (_local2);
        }
        function addDeclaration(_arg1:CSSDeclaration, _arg2:String):void{
            var _local6:String;
            var _local3:CSSDeclarationListItem = new CSSDeclarationListItem(_arg2, _arg1, m_declarationIndex++);
            var _local4:String = _arg2.split(" ").pop().split("#").join("@#").split(".").join("@.").split(":").join("@:");
            var _local5:Array = _local4.split("@");
            for each (_local6 in _local5) {
                if (!_local6){
                } else {
                    if (_local6 == "*"){
                        m_starSelectors.push(_local3);
                    } else {
                        if (".:#".indexOf(_local6.charAt(0)) == -1){
                            _local6 = _local6.toLowerCase();
                        };
                        if (!m_selectorHeadParts[_local6]){
                            m_selectorHeadParts[_local6] = [];
                        };
                        m_selectorHeadParts[_local6].push(_local3);
                    };
                };
            };
            m_items.push(_local3);
        }

    }
}//package reprise.css 
